const { defineConfig } = require("@vue/cli-service")
const  CompressionPlugin = require("compression-webpack-plugin")
const isProduction = process.env.NODE_ENV === 'production'
module.exports = defineConfig({
  productionSourceMap: false,
  publicPath: '/',
  devServer: {
    open: true, // 自动打开浏览器
    port: 8080, // 指定端口号
    proxy:{
      "/api": {
        target: "http://192.168.0.222", 
        ws: true,
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          "^/api": "",
        },
      }
    }
  },
  chainWebpack: config => {
    if(isProduction) {
      config.plugin('compressionPlugin').use(new CompressionPlugin({
        algorithm: 'gzip',
        test:/\.js$|\.css$|\.html$/,
        threshold: 10240,
        minRatio: 0.8,
        deleteOriginalAssets: false
      }))
    }
   
  }
})
